package com.one.friend.controller.user;

import com.one.api.domain.vo.UserQuestionResultVO;
import com.one.common.core.controller.BaseController;
import com.one.common.core.domain.R;
import com.one.friend.aspect.CheckUserStatus;
import com.one.friend.domain.user.dto.UserSubmitDTO;
import com.one.friend.service.user.IUserQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {

    @Autowired
    private IUserQuestionService iUserQuestionService;

    //用户提交代码
    @PostMapping("/submit")
    public R<UserQuestionResultVO> submit(@RequestBody UserSubmitDTO userSubmitDTO){
        return iUserQuestionService.submit(userSubmitDTO);
    }

    //rabbit版用户提交代码
    @PostMapping("/rabbit/submit")
    @CheckUserStatus
    public R<Void> rabbitSubmit(@RequestBody UserSubmitDTO userSubmitDTO){
        return toR(iUserQuestionService.rabbitSubmit(userSubmitDTO));
    }

    //获取题目提交的结果
    @GetMapping("/exe/result")
    public R<UserQuestionResultVO> exeResult(Long questionId, Long examId, String currentTime){
        return R.ok(iUserQuestionService.exeResult(questionId,examId,currentTime));
    }
}
